﻿using System;
using System.Collections.Generic;
using System.Data;
using MuZa.DBConnector;

namespace MuZa.MuZa
{
    internal class Initiator
    {
        private String Id;
        private String Location;
        private String Name;
        private List<String> Priority = new List<String>();

        private List<Task> Tasks = new List<Task>();
        private int TotalCost;
        private int TotalDurationHours;

        private List<List<ResourceSource>> partList = new List<List<ResourceSource>>();

        /**
         * 
         */

        public Initiator()
        {
        }


        public Initiator(String Id, String Name, String Location, int TotalCost, int TotalDurationHours,
                         List<String> Priority)
        {
            this.Id = Id;
            this.Name = Name;
            this.Location = Location;
            this.TotalCost = TotalCost;
            this.TotalDurationHours = TotalDurationHours;
            this.Priority = Priority;
        }

        /**
         * 
         * @return
         */

        public String getId()
        {
            return Id;
        }

        /**
         * 
         * @param Id
         */

        public void setId(String Id)
        {
            this.Id = Id;
        }

        /**
         * 
         * @return
         */

        public String getLocation()
        {
            return Location;
        }

        /**
         * 
         * @param Location
         */

        public void setLocation(String Location)
        {
            this.Location = Location;
        }

        /**
         * 
         * @return
         */

        public String getName()
        {
            return Name;
        }

        /**
         * 
         * @param Name
         */

        public void setName(String Name)
        {
            this.Name = Name;
        }

        /**
         * 
         * @return
         */

        public List<String> getPriority()
        {
            return Priority;
        }

        /**
         * 
         * @param Priority
         */

        public void setPriority(List<String> Priority)
        {
            this.Priority = Priority;
        }

        /**
         * 
         * @param pri 
         */

        public void addPriorityToList(String pri)
        {
            Priority.Add(pri);
        }


        /**
         * 
         * @return
         */

        public int getTotalCost()
        {
            return TotalCost;
        }

        /**
         * 
         * @param TotalCost
         */

        public void setTotalCost(int TotalCost)
        {
            this.TotalCost = TotalCost;
        }

        /**
         * 
         * @return
         */

        public int getTotalDurationHours()
        {
            return TotalDurationHours;
        }

        /**
         * 
         * @param TotalDurationHours
         */

        public void setTotalDurationHours(int TotalDurationHours)
        {
            this.TotalDurationHours = TotalDurationHours;
        }

        /**
         * 
         * @return
         */

        public List<Task> getTasks()
        {
            return Tasks;
        }

        /**
         * 
         * @param Tasks
         */

        public void setTasks(List<Task> Tasks)
        {
            this.Tasks = Tasks;
        }

        /**
         * 
         * @param task
         */

        public void addTaskToList(Task task)
        {
            Tasks.Add(task);
        }

        /**
         * 
         */

        public void AskInfo()
        {
            //Initiator asks information from IB
            var board = new InfoBoard();
            //partList = new List<List<ResourceSource>>();


            //1. Get initiator id.
            int initId = GetData.GetInitiatorId(Name);

            //2. Get Task list.
            var dtTask = new DataTable();
            dtTask = GetData.GetAllTasksFromInitiator(initId);

            //3. Get Priority list
            var dtPriority = new DataTable();
            dtPriority = GetData.GetAllPriorityFromInitiator(initId);

            var dTable = new DataTable();
            dTable = InfoBoard.GiveInfo2(dtTask, dtPriority, Location, TotalCost, TotalDurationHours);
        }

        public void RequestToParticipant()
        {
            var dTable = new DataTable();
            //dTable = InfoBoard.GiveInfo2(this);

            //send part req
            //  init_name, resource_name, task_quantity
            //send IB NoR update

            //dTable.Rows[0].ItemArray[0]
        }
    }
}